package cn.jhc.servlet;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.jhc.dao.ConnectionFactory;
import cn.jhc.dao.NewUserDao;

@WebServlet(name = "open vote", urlPatterns = { "/houtai_openVote.do" })
public class Houtai_OpenVoteServlet extends HttpServlet {
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		req.setCharacterEncoding("UTF-8");
		String id = (String) req.getParameter("id");
		int userid = Integer.parseInt(id);
		NewUserDao dao = new NewUserDao();
		dao.setCon(ConnectionFactory.getConnection());
		dao.updateYesVote(userid);
		RequestDispatcher dispatcher = req.getRequestDispatcher("/houtai_showuser.jsp?search=no");
		dispatcher.forward(req, resp);
	}
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		doGet(req, resp);
	}
}
